package edu.base.controller;


import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.github.pagehelper.PageInfo;

import edu.base.service.CustomAdService;
import edu.base.util.HigherResponse;
import edu.base.entity.Advance;
import edu.base.entity.Custom;
import edu.base.entity.Express;
import edu.base.entity.Wxzx;
import edu.base.model.Users;

/**
 * @author 92473
 * 注意注解接口前加上@ResponseBody只返回response的json格式，就是你的返回数据
 * 不加@ResponseBody返回页面，让他控制页面，请看第一个接口，就是页面的访问
 */
@Controller
@RequestMapping("/advance")
public class CustomAdCon {
	
	@Autowired
	private CustomAdService customAdService;
	
	/*
	 * //前台登录
	 * 
	 * @RequestMapping("/login") public String clogin(){
	 * 
	 * 
	 * return "/advance/custom/login"; }
	 */
	
	//输入localhost:8080/advance/advance 即可访问到 templates/advance/custom/advance的html文件
	//前台预约
	@RequestMapping("/advance")	
	public String advance() {		
		return "/advance/custom/advance";
	}
	
	/*
	 * //前台登录
	 * 
	 * @RequestMapping("/login.do")
	 * 
	 * @ResponseBody public HigherResponse<Users> login(String username,String
	 * password,HttpSession session){ return customAdService.login(username,
	 * password ,session); }
	 */
	
	//客户查看预约信息
	@ResponseBody
	@RequestMapping("/queryAdInfo.do")
	public HigherResponse<PageInfo<Advance>> getAdvanceInfo( @RequestParam(required = true,defaultValue = "1")Integer pageNum,
			@RequestParam(required = true,defaultValue = "3")Integer pageSize ,HttpSession session){
		return customAdService.queryCustomAd(session, pageNum, pageSize);
	}
	
	//客服查询预约信息，控制页面
	@RequestMapping("/advance-manager")
	public String advanceManager() {
		return "/advance/advance-manager";
	}
	
	//客服查询预约信息
	@ResponseBody
	@RequestMapping("/queryAllAdInfo.do")
	public HigherResponse<PageInfo<Advance>> queryAllAdInfo( @RequestParam(required = true,defaultValue = "1")Integer pageNum,
			@RequestParam(required = true,defaultValue = "5")Integer pageSize,String beginTime,String endTime,Byte advanceMethod,Byte advanceStatus){
		return customAdService.queryAllAdInfo(pageNum, pageSize,beginTime,endTime,advanceMethod,advanceStatus);
	}
	
	//根据预约编号查询预约信息
	@ResponseBody
	@RequestMapping("/queryOneAdByNo.do")
	public HigherResponse<Advance> queryOneAdByNo(Integer advanceNo){
		return customAdService.queryOneAdByNo(advanceNo);
	}
	
	//客户添加预约信息
	@RequestMapping("/advance-add")
	public String addAdvance(){
		
		return "advance/custom/advance-add";
	}
	
	
	//客户添加预约信息
	@ResponseBody
	@RequestMapping("/addAdInfo.do")
	public HigherResponse<String> addAdvanceInfo(HttpSession session,Advance advance,MultipartFile multipartFile){
		
		return customAdService.addOneAdvance(session, advance, multipartFile);
	}
	
	//客户取消预约
	@ResponseBody
	@RequestMapping("/updateAdStatus.do")
	public HigherResponse<String> updateAdStatus(HttpSession session,Integer advanceId){
		
		return customAdService.updateAdStatus(session, advanceId);
	}
	
	//客户修改预约
	@ResponseBody
	@RequestMapping("/updateAdvance.do")
	public HigherResponse<String> updateAdvance(Integer advanceNo,Advance advance){
		
		return customAdService.updateAdvance(advanceNo, advance);
	}
	
	//根据名称查询维修中心
	@ResponseBody
	@RequestMapping("/queryWxzxByName.do")
	public HigherResponse<Wxzx> queryWxzxByName(String wxzxName){
		return customAdService.queryWxzxByName(wxzxName);
	}

	//查询维修中心
	@ResponseBody
	@RequestMapping("/queryWxzx.do")
	public HigherResponse<List<Wxzx>> queryAllWxzx(){
		return customAdService.queryAllWxzx();
	}
	
	//客户查询邮递信息
	@ResponseBody
	@RequestMapping("/queryExpressInfo.do")
	public HigherResponse<Express> queryExpressInfo(HttpSession session,Integer advanceNo){
		return customAdService.queryExpressInfo(session , advanceNo);
	}
	
	//客户添加邮递
	@ResponseBody
	@RequestMapping("/addOneExpress.do")
	public HigherResponse<String> addOneExpress(HttpSession session,Integer advanceNo, Express express){
		return customAdService.addOneExpress(session, advanceNo, express);
	}
	
	
	
	//查询客户的邮递信息
	@ResponseBody
	@RequestMapping("/getOneExpress.do")
	public HigherResponse<Express> getOneExpress(Integer advanceNo){
		return customAdService.getOneExpress(advanceNo);
	}
	
	//客服删除客户的预约信息
	@ResponseBody
	@RequestMapping("/deleteOneAdvance.do")
	public HigherResponse<String> deleteOneAdvance(Integer advanceNo){
		return customAdService.deleteOneAdvance(advanceNo);
	}
	
	//客服确认客户预约
	@ResponseBody
	@RequestMapping("/acceptAdvance.do")
	public HigherResponse<String> acceptAdvance(Integer advanceNo){
		return customAdService.acceptAdvance(advanceNo);
	}
	
	//客服查询邮递信息，控制页面
	@RequestMapping("/manager-express")
	public String advanceExpressString() {
		return "/advance/manager-express";
	}
	
	//客服查询客户的邮递信息	
	@ResponseBody
	@RequestMapping("/queryAllExpress.do")
	public HigherResponse<PageInfo<Express>> queryAllExpress( @RequestParam(required = true,defaultValue = "1")Integer pageNum,
			@RequestParam(required = true,defaultValue = "5")Integer pageSize,Integer advanceId,Integer userId,String expressCompany){
		return customAdService.queryAllExpress(pageNum, pageSize,advanceId,userId,expressCompany);
	}
	
	
	//客服查询维修中心信息，控制页面
	@RequestMapping("/manager-wxzx")
	public String advanceWxzx() {
		return "/advance/manager-wxzx";
	}
	//客服查询维修中心信息
	@ResponseBody
	@RequestMapping("/queryWxzxList.do")
	public HigherResponse<PageInfo<Wxzx>> queryWxzxList(@RequestParam(required = true,defaultValue = "1")Integer pageNum,
			@RequestParam(required = true,defaultValue = "5")Integer pageSize,Integer status){
		return customAdService.queryWxzxList(pageNum,pageSize,status);
	}
	
	//客服修改维修中心状态
	@ResponseBody
	@RequestMapping("/updateWxzxStatus.do")
	public HigherResponse<String> updateWxzxStatus(Integer wxzxId,Integer status){
		return customAdService.updateWxzxStatus(wxzxId,status);
	}
	
	//客服修改维修中心的管理者姓名
	@ResponseBody
	@RequestMapping("/updateWxzxManager.do")
	public HigherResponse<String> updateWxzxManager(Integer wxzxId,String wxzxManager){
		return customAdService.updateWxzxManager(wxzxId,wxzxManager);
	}
	
	//客服修改维修中心的管理者联系方式
	@ResponseBody
	@RequestMapping("/updateWxzxPhone.do")
	public HigherResponse<String> updateWxzxPhone(Integer wxzxId,String wxzxPhone){
		return customAdService.updateWxzxPhone(wxzxId,wxzxPhone);
	}
	
	//客服修改维修中心的地址
	@ResponseBody
	@RequestMapping("/updateWxzxAddress.do")
	public HigherResponse<String> updateWxzxAddress(Integer wxzxId,String wxzxAddress){
		return customAdService.updateWxzxAddress(wxzxId,wxzxAddress);
	}
	
	//客服添加维修中心信息
	@ResponseBody
	@RequestMapping("/addOneWxzx.do")
	public HigherResponse<String> addOneWxzx(Wxzx wxzx){
		return customAdService.addOneWxzx(wxzx);
	}
	
}
